import logging

from fastapi import APIRouter, Depends

from like.schema_base import PageInationResult
from like.http_base import unified_resp
from .schemas import (
    MedicalDipCoreDiseaseListIn, MedicalDipCoreDiseaseExportIn, MedicalDipCoreDiseaseDetailIn, MedicalDipCoreDiseaseAddIn, 
    MedicalDipCoreDiseaseEditIn, MedicalDipCoreDiseaseDelIn, MedicalDipCoreDiseaseOut)
from .service import IMedicalDipCoreDiseaseService, MedicalDipCoreDiseaseService

logger = logging.getLogger(__name__)

router = APIRouter(prefix='/Disease')


@router.get('/list', response_model=PageInationResult[MedicalDipCoreDiseaseOut])
@unified_resp
async def Disease_list(
        list_in: MedicalDipCoreDiseaseListIn = Depends(),
        medical_dip_core_disease_service: IMedicalDipCoreDiseaseService = Depends(MedicalDipCoreDiseaseService.instance)):
    """存储DIP正式目录相关信息的列表"""
    result = await medical_dip_core_disease_service.list(list_in)
    # result.file_name = "存储DIP正式目录相关信息的"
    return result

@router.get('/export', response_model=bytes)
@unified_resp
async def Disease_export(export_in: MedicalDipCoreDiseaseExportIn = Depends(), MedicalDipCoreDisease_service: IMedicalDipCoreDiseaseService = Depends(MedicalDipCoreDiseaseService.instance)):
    return await MedicalDipCoreDisease_service.export_excel(export_in)


@router.get('/detail')
@unified_resp
async def Disease_detail(
        detail_in: MedicalDipCoreDiseaseDetailIn = Depends(),
        medical_dip_core_disease_service: IMedicalDipCoreDiseaseService = Depends(MedicalDipCoreDiseaseService.instance)):
    """存储DIP正式目录相关信息的详情"""
    return await medical_dip_core_disease_service.detail(detail_in.id)


@router.post('/add')
@unified_resp
async def Disease_add(
        add_in: MedicalDipCoreDiseaseAddIn,
        medical_dip_core_disease_service: IMedicalDipCoreDiseaseService = Depends(MedicalDipCoreDiseaseService.instance)):
    """存储DIP正式目录相关信息的新增"""
    return await medical_dip_core_disease_service.add(add_in)


@router.post('/edit')
@unified_resp
async def Disease_edit(
        edit_in: MedicalDipCoreDiseaseEditIn,
        medical_dip_core_disease_service: IMedicalDipCoreDiseaseService = Depends(MedicalDipCoreDiseaseService.instance)):
    """存储DIP正式目录相关信息的编辑"""
    return await medical_dip_core_disease_service.edit(edit_in)


@router.post('/del')
@unified_resp
async def Disease_del(
        del_in: MedicalDipCoreDiseaseDelIn,
        medical_dip_core_disease_service: IMedicalDipCoreDiseaseService = Depends(MedicalDipCoreDiseaseService.instance)):
    """存储DIP正式目录相关信息的删除"""
    return await medical_dip_core_disease_service.delete(del_in.id)
